import React, { useEffect, useState } from 'react';
import { Menu } from 'antd';
import { ContextMenu } from 'gg-editor';

const MindContextMenu = props => {
  const { node, eventObj, menuClick, disabled } = props;

  return (
    <div
      style={{
        position: 'absolute',
        top: eventObj?.canvasY,
        left: eventObj?.canvasX,
        display: eventObj ? 'block' : 'none',
      }}
    >
      <Menu mode="vertical" selectable={false} onClick={menuClick}>
        {node?.nodeType != 0 ?<Menu.Item key="edit">编辑</Menu.Item> : ''} 
        {/* {node?.nodeType === 'root' ? <Menu.Item key="addChild">插入选项</Menu.Item> : ''} */}
        {/* {node?.nodeType === 'second' ? <Menu.Item key="addQuestion">插入话术</Menu.Item> : ''}
        {node?.nodeType === 'second' ? <Menu.Item key="addAnswer">插入答案</Menu.Item> : ''} */}
        {node?.nodeType === 0 ? <Menu.Item key="addChild">插入选项</Menu.Item> : ''}
        {node?.nodeType === 1 ? (
          <Menu.Item key="addQuestion" disabled={disabled}>
            插入话术
          </Menu.Item>
        ) : (
          ''
        )}
        {node?.nodeType === 1 ? (
          <Menu.Item key="addAnswer" disabled={disabled}>
            插入答案
          </Menu.Item>
        ) : (
          ''
        )}
        <Menu.Item key="del">删除</Menu.Item>
      </Menu>
    </div>
  );
};

export default MindContextMenu;
